import React from 'react';
import Item, { IFormItemProps } from './Item'
import Select, { SelectProps } from 'antd/lib/select';


const Option = Select.Option;

interface ISelectProps extends SelectProps, IFormItemProps {
	options: Array<{ name: string, value: string | number }>

}
export default class FormSelect extends React.Component<ISelectProps> {
	renderSelect = () => {
		let { options, ...restProps } = this.props
		// console.log("select-props::", restProps)
		return (
			<Select {...restProps} mode={restProps.mode}>
				{options.map(option => {
					const { value, name } = option;
					return (
						<Option
							key={value}
							value={value}>
							{name}
						</Option>
					)
				})}
			</Select>
		)
	}
	render() {
		let { options, ...resProps } = this.props;
		return (<Item {...resProps} render={this.renderSelect} />)

	}
}